import 'package:flutter/material.dart';
import 'package:p_location/alarm/res/alarm_vehicle_item.dart';
import 'package:p_location/common/widget/tag_view.dart';
import 'package:p_location/utils/navigator_util.dart';

class MajorHazardListItem extends StatelessWidget {
  final AlarmVehicleItem _majorHazardObj;

  const MajorHazardListItem(this._majorHazardObj);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
//        NavigatorUtil.push(context, IotMajorHazardDetailPage(_majorHazardObj));
      },
      child: Card(
        margin: EdgeInsets.only(left: 10, right: 10, bottom: 10),
        child: Container(
          decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(10))),
          child: Stack(
            alignment: Alignment.centerLeft,
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(left: 15, top: 15, bottom: 15),
                padding: EdgeInsets.only(left: 0, right: 10),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        TagView(
                          _majorHazardObj.alarmType,
                          paddingLeft: 12,
                          paddingBottom: 1,
                          paddingRight: 12,
                          paddingTop: 1,
                          fillColor: Colors.white,
                          strokeColor: Colors.red,
                          textColor: Colors.red,
                          radius: 2,
                        ),
                        Text(
                          _majorHazardObj.alarmTime,
                          style: TextStyle(color: Color.fromARGB(99, 0, 0, 0)),
                        )
                      ],
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 5),
                      alignment: Alignment.centerLeft,
                      child: Text(_majorHazardObj.alarmInfo),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 5),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            _majorHazardObj.status,
                            style: TextStyle(
                                fontSize: 12,
                                color: _majorHazardObj.status == '报警中'
                                    ? Colors.red
                                    : Colors.grey),
                          ),
                          TagView(
                            "追踪",
                            paddingLeft: 15,
                            paddingRight: 15,
                            paddingTop: 1,
                            paddingBottom: 1,
                            radius: 5,
                            strokeColor: Color.fromARGB(255, 56, 160, 253),
                            textColor: Color.fromARGB(255, 56, 160, 253),
                            fillColor: Colors.white,
                            onPress: (){
                              NavigatorUtil.jumpToLocationPage(context);
                            },
                          )
                        ],
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
